export class Utils {
  static async asyncSleep(ms: number) {
    return new Promise(resolve => setTimeout(resolve, ms))
  }
}

export interface IImgBlock {
  imgSrc?: string
  title?: string
  sortText?: string
  userName: string
  headImg: string
  likeCount: number
  collectCount: number
  liked: boolean
  collected: boolean
  commentCount: number
}

export interface IUserInfo {
  userId: number
  userName: string
  userHead: string
}

export function isPhone(): boolean {
  let m = (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i));
  return m != null && m.length != 0
}

export interface ILoginResult {
  success: boolean
  userInfo?: IUserInfo
  token?: string
}

export const LOCAL_LOGIN = "L_LOGIN"

export const DEFAULT_USER: IUserInfo = {
  userId: 0,
  userHead: "",
  userName: "游客"
};
